import cPickle as pickle
import sys

STDSIZE = 20
def printdone():
    sys.stdout.write("[DONE]\n")

def printw(s, w):
    sys.stdout.write(s)
    while len(s)<w:
        sys.stdout.write(" ")
        w = w - 1
    sys.stdout.flush()

def dry_run(run_function):
    printw("Loading data", STDSIZE)
    dump = open("dump.glx", "rb")
    data = pickle.load(dump)
    dump.close()
    printdone()

    print "--- Starting ---"
    return run_function(data)    

def test(test_f, cmp_function):

    printw("Loading data", STDSIZE)
    dump = open("dump.glx", "rb")
    data = pickle.load(dump)
    dump.close()
    printdone()

    print "--- Starting ---"
    return cmp_function(test_f, data)
